package com.juneng.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.R;
import com.juneng.utils.Func;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.juneng.entity.SmsBannerBook;
import com.juneng.dto.SmsBannerBookDto;
import com.juneng.dto.SmsBannerBookQueryDto;
import com.juneng.vo.SmsBannerBookVo;
import com.juneng.service.ISmsBannerBookService;

/**
 * 书籍轮播图表 控制器
 *
 * @author zds
 * @since 2021-07-15
 */
@RestController
@AllArgsConstructor
@RequestMapping("smsBannerBook/v1")
@Api(tags = "书籍轮播图表相关接口")
public class SmsBannerBookController {

	private ISmsBannerBookService smsBannerBookService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<SmsBannerBook> detail(Integer id) {
		SmsBannerBook detail = smsBannerBookService.getById(id);
		return R.success(detail);
	}

	/**
	 * 分页 书籍轮播图表
	 */
	@GetMapping("/page")
	@ApiOperation(value = "分页", notes = "传入smsBannerBook")
	public R<IPage<SmsBannerBookVo>> page(SmsBannerBookQueryDto dto) {
		IPage<SmsBannerBookVo> pages = smsBannerBookService.page(dto);
		return R.success(pages);
	}
	/**
	 * 列表 书籍轮播图表
	 */
	@GetMapping("/list")
	@ApiOperation(value = "不分页", notes = "传入smsBannerBook")
	public R<List<SmsBannerBook>> list(SmsBannerBookQueryDto dto) {
		List<SmsBannerBook> list = smsBannerBookService.list(dto);
		return R.success(list);
	}

	/**
	 * 新增 书籍轮播图表
	 */
	@PostMapping("/save")
	@ApiOperation(value = "新增", notes = "传入smsBannerBook")
	public R save(@RequestBody SmsBannerBookDto dto) {
		return R.success(smsBannerBookService.save(dto));
	}

	/**
	 * 修改 书籍轮播图表
	 */
	@PutMapping("/update")
	@ApiOperation(value = "修改", notes = "传入smsBannerBook")
	public R update(@RequestBody SmsBannerBookDto dto) {
		return R.success(smsBannerBookService.updateById(dto));
	}

	/**
	 * 删除 书籍轮播图表
	 */
	@DeleteMapping("/remove")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.success(smsBannerBookService.deleteLogic(Func.toIntList(ids)));
	}
}
